<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:replace="~{::title}">网上跳蚤市场</title>
    <link rel="stylesheet" th:href="@{/css/style.css}" />
</head>
<body>
<div class="nav-wrapper">
    <div class="nav">
        <div class="nav-left">
            <a th:href="@{/products}"
               th:if="${#httpServletRequest.requestURI != '/login' && #httpServletRequest.requestURI != '/register'}"
               th:class="${#httpServletRequest.requestURI == '/products' ? 'active' : ''}">商品</a>
            <a th:href="@{/cart}" th:if="${session.user != null && session.user.role != 'guest'}" th:class="${#httpServletRequest.requestURI == '/cart' ? 'active' : ''}">购物车</a>
            <a th:href="@{/orders}" th:if="${session.user != null && session.user.role != 'guest'}" th:class="${#httpServletRequest.requestURI == '/orders' ? 'active' : ''}">购买订单</a>
            <a th:href="@{/my-products}" th:if="${session.user != null && session.user.role != 'guest'}" th:class="${#httpServletRequest.requestURI == '/my-products' ? 'active' : ''}">我的商品</a>
            <a th:href="@{/seller-orders}" th:if="${session.user != null && session.user.role != 'guest'}" th:class="${#httpServletRequest.requestURI == '/seller-orders' ? 'active' : ''}">我的订单</a>
            <a th:href="@{/my-reviews}" th:if="${session.user != null && session.user.role != 'guest'}" th:class="${#httpServletRequest.requestURI == '/my-reviews' ? 'active' : ''}">我的评价</a>
        </div>
        <div class="nav-right">
            <a th:href="@{/admin}" th:if="${session.user != null and (session.user.role == 'admin' or session.user.role == 'category_admin')}" th:class="${#httpServletRequest.requestURI == '/admin' ? 'active' : ''}">后台管理</a>
            <a th:href="@{/login}" th:if="${session.user == null}" th:class="${#httpServletRequest.requestURI == '/login' ? 'active' : ''}">登录</a>
            <a th:href="@{/register}" th:if="${session.user == null}" th:class="${#httpServletRequest.requestURI == '/register' ? 'active' : ''}">注册</a>
            <span th:if="${session.user != null && session.user.role == 'guest'}" class="status-tag status-pending">游客模式</span>
            <span th:if="${session.user != null}" class="welcome-text">欢迎, <b th:text="${session.user.username}"></b></span>
            <a th:href="@{/profile}" th:if="${session.user != null && session.user.role != 'guest'}" th:class="${#httpServletRequest.requestURI == '/profile' ? 'active' : ''}">个人资料</a>
            <a th:href="@{/logout}" th:if="${session.user != null && session.user.role != 'guest'}">退出</a>
            <a th:href="@{/guest-logout}" th:if="${session.user != null && session.user.role == 'guest'}">退出游客模式</a>
        </div>
    </div>
</div>
<div class="container">
    <div th:replace="~{::section}" class="fade-in"></div>
</div>
<footer class="footer">
    <div class="container">
        <p>&copy; 2025 网上跳蚤市场 - 提供二手商品交易平台</p>
    </div>
</footer>
</body>
</html> 